<template>
  <div class="win007">
    <div class="page-body">
      <a-form :form="form" :self-update="true">
        <a-form-item :colon="false">
          <span slot="label">
            香港低于澳门
          </span>
          <a-input v-decorator="['intervalL', intervalOpts]" placeholder="请输入" allow-clear />
        </a-form-item>
        <a-form-item :colon="false">
          <span slot="label">
            香港高于澳门
          </span>
          <a-input v-decorator="['intervalH', intervalOpts]" placeholder="请输入" allow-clear />
        </a-form-item>
      </a-form>
      <div class="btn-wrap">
        <a-button type="primary" :loading="loading" @click="save">获取数据</a-button>
      </div>
      <a-card class="data-wrap">
        <a v-for="url in urlList" :key="url" :href="url" target="_blank">{{url}}</a>
      </a-card>
    </div>
  </div>
</template>

<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
  name: 'PageToolWin007',
  layout: 'tool',
  data () {
    return {
      form: this.$form.createForm(this),
      intervalOpts: {
        rules: [
          {
            required: true,
            message: '不能为空！'
          },
          {
            pattern: /^([\d.]*)+$/,
            message: '请输入数值'
          }
        ]
      },
      urlList: [],
      loading: false
    };
  },
  mounted () {
    this.setForm({
      intervalL: 0,
      intervalH: 0.1
    });
  },
  methods: {
    setForm (settings) {
      this.form.setFieldsValue({
        intervalL: settings.intervalL,
        intervalH: settings.intervalH
      });
    },
    save () {
      if (this.loading) {
        return;
      }
      this.loading = true;
      this.form.validateFieldsAndScroll((error, values) => {
        if (!error) {
          this.$axios.$get('/api/tool/win007', { params: values }).then(({ code, data }) => {
            if (code === 1) {
              this.urlList = data;
            }
            this.loading = false;
          }, () => {
            this.loading = false;
          });
        }
      });
    }
  }
});
</script>

<style scoped>
.ant-upload-select-picture-card i {
  font-size: 32px;
  color: #777;
}

.ant-upload-select-picture-card .ant-upload-text {
  margin-top: 8px;
  color: #666;
}

.img-tip {
  font-size: 12px;
  line-height: 1;
  margin: 2px 0 17px;
}

.img-tip i {
  position: relative;
  /* top: -1px; */
}

.btn-wrap {
  margin-top: 30px;
}

.btn-wrap button {
  margin-right: 20px;
}

.data-wrap{
  margin-top: 30px;
}
</style>
